<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>__proto__是属性访问器</title>
</head>
<body>
    <script>
        let hd = {name:"hd"};
        hd.__proto__ = {
            show(){
                console.log(this.name);
            }
        };

        // 将hd.__proto__赋值为99，还是能调用show方法,说明hd.__proto__并没有改变
        hd.__proto__ = 99;
        hd.show();
        console.log(hd);


        // __proto__内部原理：
        let hdms = {
            action:{},
            get proto(){
                return this.action
            },
            set proto(obj){
                if(typeof obj == "object"){
                    this.action = obj;
                }
            }
        };
        // 字符串没有改变action
        hdms.proto = "abc";
        console.log(hdms.proto);
        // 对象改变了action
        hdms.proto = {tag:"好好学习"};
        console.log(hdms.proto);



        // 如果非要把__proto__改成99，就让对象不要有原型,__proto__只是它的一个属性
        let xiasnn = {name:"xiaxia"};
        Object.setPrototypeOf(xiasnn,null);
        xiasnn.__proto__ = {
            show(){
                console.log(this.name);
            }
        };
        xiasnn.__proto__ = 99;
        console.log(xiasnn.__proto__);

    </script>
</body>
</html>